﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace ZoambieGaem {
    class Zoambie {

        public float transparency;
        public Color color;

        //Konstruktööri
        public Zoambie(Texture2D texture, int x, int y, Master m) {
            this._death = false;
            this.transparency = 255f;
            this._health = 20;
            this._picturesLeft = 0;
            this._texture = texture;
            this._angle = MathHelper.ToRadians(90);
            this._worldPosition = new Vector2(x, y);
            Random randNum = new Random();
            this._speed = randNum.NextDouble() * 1;
            if (this._speed < 0.2)
                this._speed = 0.2;

            this._width = (int)(this.texture.Width * m.drawScale);
            this._height = (int)(this.texture.Height * m.drawScale);
            this._centerX = this.texture.Width / 2;
            this._centerY = this.texture.Height / 2;
            this._aStarUpdate = 1000;
            this._movementMethod = 2;
            this._path = new LinkedList<Node>();
            this._lineOfSight = true;
            this._routeFound = true;
        }

        static readonly object deathLocker = new object();
        private Boolean _death;
        public Boolean death
        {
            get
            {
                lock (deathLocker)
                {
                    return _death;
                }
            }
            set
            {
                lock (deathLocker)
                {
                    _death = value;
                }
            }
        }


        static readonly object healthLocker = new object();
        private int _health;
        public int health {
            get {
                lock (healthLocker) {
                    return _health;
                }
            }
            set {
                lock (healthLocker) {
                    _health = value;
                }
            }
        }

        static readonly object picturesLeftLocker = new object();
        private int _picturesLeft;
        public int picturesLeft {
            get {
                lock (picturesLeftLocker) {
                    return _picturesLeft;
                }
            }
            set {
                lock (picturesLeftLocker) {
                    _picturesLeft = value;
                }
            }
        }

        static readonly object textureLocker = new object();
        private Texture2D _texture;
        public Texture2D texture {
            get {
                lock (textureLocker) {
                    return _texture;
                }
            }
            set {
                lock (textureLocker) {
                    _texture = value;
                }
            }
        }

        static readonly object worldPositionLocker = new object();
        private Vector2 _worldPosition;
        public Vector2 worldPosition {
            get {
                lock (worldPositionLocker) {
                    return _worldPosition;
                }
            }
            set {
                lock (worldPositionLocker) {
                    _worldPosition = value;
                }
            }
        }

        static readonly object zombieDirectionLocker = new object();
        private Vector2 _zombieDirection;
        public Vector2 zombieDirection {
            get {
                lock (zombieDirectionLocker) {
                    return _zombieDirection;
                }
            }
            set {
                lock (zombieDirectionLocker) {
                    _zombieDirection = value;
                }
            }
        }

        static readonly object angleLocker = new object();
        private float _angle;
        public float angle {
            get {
                lock (angleLocker) {
                    return _angle;
                }
            }
            set {
                lock (angleLocker) {
                    _angle = value;
                }
            }
        }

        static readonly object wantedAngleLocker = new object();
        private float _wantedAngle;
        public float wantedAngle {
            get {
                lock (wantedAngleLocker) {
                    return _wantedAngle;
                }
            }
            set {
                lock (wantedAngleLocker) {
                    _wantedAngle = value;
                }
            }
        }

        static readonly object speedLocker = new object();
        private double _speed;
        public double speed {
            get {
                lock (speedLocker) {
                    return _speed;
                }
            }
            set {
                lock (speedLocker) {
                    _speed = value;
                }
            }
        }

        static readonly object widthLocker = new object();
        private int _width;
        public int width {
            get {
                lock (widthLocker) {
                    return _width;
                }
            }
            set {
                lock (widthLocker) {
                    _width = value;
                }
            }
        }

        static readonly object heightLocker = new object();
        private int _height;
        public int height {
            get {
                lock (heightLocker) {
                    return _height;
                }
            }
            set {
                lock (heightLocker) {
                    _height = value;
                }
            }
        }

        static readonly object centerXLocker = new object();
        private int _centerX;
        public int centerX {
            get {
                lock (centerXLocker) {
                    return _centerX;
                }
            }
            set {
                lock (centerXLocker) {
                    _centerX = value;
                }
            }
        }

        static readonly object centerYLocker = new object();
        private int _centerY;
        public int centerY {
            get {
                lock (centerYLocker) {
                    return _centerY;
                }
            }
            set {
                lock (centerYLocker) {
                    _centerY = value;
                }
            }
        }

        static readonly object aStarUpdateLocker = new object();
        private int _aStarUpdate;
        public int aStarUpdate {
            get {
                lock (aStarUpdateLocker) {
                    return _aStarUpdate;
                }
            }
            set {
                lock (aStarUpdateLocker) {
                    _aStarUpdate = value;
                }
            }
        }

        static readonly object pathLocker = new object();
        private LinkedList<Node> _path;
        public LinkedList<Node> path {
            get {
                lock (pathLocker) {
                    return _path;
                }
            }
            set {
                lock (pathLocker) {
                    _path = value;
                }
            }
        }

        static readonly object movementMethodLocker = new object();
        private int _movementMethod;
        public int movementMethod {
            get {
                lock (movementMethodLocker) {
                    return _movementMethod;
                }
            }
            set {
                lock (movementMethodLocker) {
                    _movementMethod = value;
                }
            }
        }

        static readonly object lineOfSightLocker = new object();
        private Boolean _lineOfSight;
        public Boolean lineOfSight {
            get {
                lock (lineOfSightLocker) {
                    return _lineOfSight;
                }
            }
            set {
                lock (lineOfSightLocker) {
                    _lineOfSight = value;
                }
            }
        }

        static readonly object routeFoundLocker = new object();
        private Boolean _routeFound;
        public Boolean routeFound {
            get {
                lock (routeFoundLocker) {
                    return _routeFound;
                }
            }
            set {
                lock (routeFoundLocker) {
                    _routeFound = value;
                }
            }
        }
    }
}
